package cn.ycc1;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ycc
 * @date 2024/6/2
 */
public class Test {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) ac.getBean("userService");
        userService.test("李四", 18);
        userService.test("王五", 19);
        String[] beanNamesForType = ac.getBeanNamesForType(UserService.class);
        for (String beanName : beanNamesForType) {
            System.out.println(beanName);
        }

        String[] beanDefinitionNames = ac.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
    }
}
